<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div class="wrap">
      <canvas id="canvas" height="400" width="600"></canvas>
    </div>
  </body>

  <script>
    const canvas = document.getElementById('canvas')
    const ctx = canvas.getContext('2d')

    const width = 600
    const height = 400

    ctx.fillStyle = 'red'
    ctx.fillRect(100, 100, 100, 100)

    const imagedata = ctx.getImageData(0, 0, 200, 200)
    ctx.clip()

    // ctx.fillStyle = 'blue'
    // ctx.fillRect(0, 0, 600, 400)
    ctx.putImageData(imagedata, 100, 100)
  </script>
</html>
